<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
request.setAttribute("basePath", basePath);
String baseInfoJson= (String)request.getAttribute("baseInfoJson");
%>
<link rel="stylesheet" href="${basePath}assets/bootstrap/css/bootstrap.css"/>
<link rel="stylesheet" href="${basePath}assets/jquery-ui/jquery-ui.css"/>
<link rel="stylesheet" href="${basePath}assets/css/basic.css"/>
<link rel="stylesheet" href="${basePath}assets/css/medical_record/home_page.css"/>
<script type="text/javascript" src="${basePath}assets/js/jquery/jquery.min.js"></script>
<script type="text/javascript" src="${basePath}assets/bootstrap/js/bootstrap.js"></script>
<script type="text/javascript" src="${basePath}assets/jquery-ui/jquery-ui.js"></script>
<script  type="text/javascript" src="${basePath}/static/layer/layer.js"></script>
<link href="${basePath}/static/layer/layer_defined.css" rel="stylesheet" type="text/css">


<form action="${basePath }medical_record/edit_home_page_nurse" style="height:auto" method="post">
	<input type="hidden" id="visitGuid" name="visitGuid" value="${visitGuid }">
	<input type="hidden" id="mrId" value="${mrId}">
	<input type="hidden" id="visitNumber" value="${visitNumber}">
	
	<table style="width:100%;" cellspacing="0" cellpadding="0">
		<tbody>
			<tr>
				<td align="left" colspan="6" class="dark">
					<div style="float:right">
						<input type="submit" value="保存" class="btn">&nbsp;
					</div>
				<!-- 	<div style="float:right">
						<a href="javascript:repeatFetchNurseInfo()" class="btn" style="width: 80px;">重新提取</a>&nbsp;
					</div> -->
					<div style="float:right">
						<a href="javascript:checkNurseInfo()" class="btn" style="width: 110px;">护理记录核对</a>&nbsp;
					</div>
                </td>
			</tr>
			<tr>
				<td align="left" class="tdLabel_7">病危天数</td>
				<td class="tdLabel_8">
					<input type="text" name="criticalDayNumber" value="${nurseInfo.criticalDayNumber}">
				</td>
				<td align="left" class="tdLabel_7">病重天数</td>
				<td class="tdLabel_8">
					<input type="text" name="sickDayNumber" value="${nurseInfo.sickDayNumber}">
				</td>

				<td align="left" class="tdLabel_7">特级护理天数</td>
				<td class="tdLabel_8">
					<input type="text" name="specialNurseDayNumber"
					value="${nurseInfo.specialNurseDayNumber}">
				</td>

			</tr>
			<tr>
				<td align="left" class="tdLabel_7">一级护理天数</td>
				<td class="tdLabel_8"><input type="text" name="firstLevelNurseDayNumber"
					value="${nurseInfo.firstLevelNurseDayNumber}">
				</td>
				<td align="left" class="tdLabel_7">二级护理天数</td>
				<td class="tdLabel_8">
					<input type="text" name="secondLevelNurseDayNumber"
					value="${nurseInfo.secondLevelNurseDayNumber}">
				</td>
				<td align="left" class="tdLabel_7">三级护理天数</td>
				<td class="tdLabel_8"><input type="text" name="threeLevelNurseDayNumber"
					value="${nurseInfo.threeLevelNurseDayNumber}">
				</td>
			</tr>
		    <tr>
				<td colspan="6" style="border:none;">
					<div style="padding:10px;">
						<a class="int" onclick="getInfo(5)">病重护理记录</a>
						<a class="int" onclick="getInfo(6)">特别护理记录</a>
						<a class="int" onclick="getInfo(7)">病危护理记录</a>
						<a class="int" onclick="getInfo(8)">一般护理记录</a>
					</div>
				
                </td>
			</tr>
		</tbody>
	</table>
</form>

<div id="content" style="overflow:auto; padding:10px 0 0 0; width:100%; height:580px;">

</div>

<script>
    getInfo(5);
	function getInfo(typeId){
		var url = "${basePath}medical_record/ajaxPdfPigeonhole";
		var dataform = {"firstGuid": $("#visitGuid").val(),"typeId":typeId};
		$.ajax({
		    type:"get",
		    url:url,
		    dataType:"json",
		    data:dataform,
		    beforeSend:function(){
		    	 $("#content").html("");
    	 	},
		    success:function(result){
		    	 if(result.success){
		        	 var data = result.data;
		        	/*  var jsonStr=JSON.parse(data.jsonStr);
		        	 if(jsonStr==null){
		        		 layer.alert("暂无数据",{icon:7});
		        		 return;
		        	 }
		        	 if(!jsonStr.recordSheet){
		        		 layer.alert("暂无数据",{icon:7});
		        		 return;
		        	 } */
		        	
		        	var imgData = data.imgList;
		        	var imgUrl = data.imgUrl;
		        	
		        	if (data != null && null != imgData && imgData.length > 0) {
		        		 var content = "";
		            	   $.each(imgData, function(i, item){
		            	     	content+="<img style='margin-bottom:20px; width:100%;display:block;' src="+item+">";
		            	   });
		            	   $("#content").html(content);
		        	} else {
		        		layer.alert("暂无数据",{icon:7});
		        		 return;
		        	}
		        	 
		        	/*  if(typeId==5){//病重
		        		 imgData=jsonStr.recordSheet.nurseRecord.IllNurseRecord.imageFilePathList;
		        	 }else if(typeId==6){//特别
		        		 imgData=jsonStr.recordSheet.nurseRecord.specialNurseRecord.imageFilePathList; 
		        	 }else if(typeId==7){//病危
		        		 imgData=jsonStr.recordSheet.nurseRecord.criticalCareRecord.imageFilePathList; 
		        	 }else if(typeId==8){//一般
		        		 imgData=jsonStr.recordSheet.nurseRecord.generalNurseRecord.imageFilePathList; 
		        	 }
		        	var imgUrl=data.imgUrl;
		        	//console.log(jsonStr.recordSheet)
		             if (data != null&&imgData!=null&&imgData.length>0) {
		            	   var content = "";
		            	   $.each(imgData, function(i, item){
		            	     	content+="<img style='margin-bottom:20px;width:100%;' src="+imgUrl+item+">";
		            	   });
		            	   $("#content").html(content);
		               }else{
		            	   $("#content").html("");
		            	   layer.alert("暂无数据",{icon:7});
		               }      */
		         }else{
		            layer.alert(result.msg,{icon:7});
		         }
		    },
		    error:function(XMLHttpRequest, textStatus, errorThrown) {
		          if(XMLHttpRequest.status == 403) {
		                 layer.alert("没有权限!",{icon:7});
		          }
		    } 
		}); 	
	}
	
	function repeatFetchNurseInfo() {
		 var loadingIndex = null;
         var visitGuid = $("#visitGuid").val();
         var visitNumber = $("#visitNumber").val();
         var mrId = $("#mrId").val();

         layer.confirm("您确定重新提取护理记录吗?",{
      	 	btn : [ '确定', '取消' ]//按钮
  			 }, function(index) {
         layer.close(index);
         jQuery.support.cors = true;
         $.ajax({
                type:"get",
            	 //url:"http://localhost:28088/medical-export/export305/ajaxRepeactPdfRecordSheetFormNurse", 
                 url:"http://132.147.0.48:8090/medical-export/export305/ajaxRepeactPdfRecordSheetFormNurse",
                data:{'visitGuid':visitGuid, 'mrId':mrId, 'visitNumber':visitNumber},
                beforeSend:function(){
                          loadingIndex = layer.load(1, {
                               shade: [0.1,'#fff'] //0.1透明度的白色背景
                    });
                },
                success:function(data){
                      console.log(data);
                      layer.close(loadingIndex);
                      if(data.success) {
                             layer.alert("成功", {icon:1});
                             window.location = '${basePath}medical_record/edit_home_page_nurse_form?visitGuid='+visitGuid;
                      } else {
                             layer.alert(data.msg, {icon:2});
                      }
                },
                error:function(){
                      layer.close(loadingIndex);
                      layer.alert('服务器异常!',{icon:2});
                }
        	 });
 		  })
	}		
	
	//核对护理记录单
	function checkNurseInfo() {
		var content = "";
		content+='<ul style="padding: 20px; font-size: 20px;">';
		content+="<li style='height: 50px; width: 200px;  float:left;'><a href='javascript:goNurseInfoPdf(1)'>病重护理记录</a><li>";
		content+="<li style='height: 50px; width: 200px;  float:left;'><a href='javascript:goNurseInfoPdf(2)'>特别护理记录</a><li>";
		content+="<li style='height: 50px; width: 200px;  float:left;'><a href='javascript:goNurseInfoPdf(3)'>病危护理记录</a><li>";
		content+="<li style= 'height: 50px;  width: 200px;  float:left;'><a href='javascript:goNurseInfoPdf(4)'>一般护理记录</a><li>";
		content+="<li style='height: 50px;  width: 200px;  float:left;'><a href='javascript:goNurseInfoPdf(5)'>体温单</a><li>";
		content+="<li style='height: 50px;  width: 200px;  float:left;'><a href='javascript:goNurseInfoPdf(6)'>血糖测定</a><li>";
		content+="<li style='height: 50px; width: 200px;  float:left;'><a href='javascript:goNurseInfoPdf(7)'>心电检测</a><li>";
		content+="<li style='height: 50px;  width: 200px;  float:left;'><a href='javascript:goNurseInfoPdf(8)'>生命体征观察</a><li>";
		content+="</ul>"; 
		
		layer.open({
		    type: 1,
		    title: '核对护理记录',   //标题
		    area: ['440px', '315px'],   //宽高
		    shade: 0.4,   //遮罩透明度
		    content: content,//支持获取DOM元素
		    btn: ['重新提取', '关闭'], //按钮组
		    scrollbar: false ,//屏蔽浏览器滚动条
		    yes: function(index){//layer.msg('yes');    //点击确定回调
		        layer.close(index);
		        repeatFetchNurseInfo();
		    },
		    btn2: function(){//layer.alert('aaa',{title:'msg title'});  ////点击取消回调
		       layer.closeAll();
		    }
		})
	}
	
	function goNurseInfoPdf(nurseType) {
		
        var visitNumber = $("#visitNumber").val();
        var mrId = $("#mrId").val();
        var remoteUrl = "http://132.147.0.8:8099/"+mrId+"_"+visitNumber+"_";
		//var remoteUrl = "http://localhost:8090/upload/"+mrId+"_"+visitNumber+"_";
		if (nurseType == 1) {
			remoteUrl+="bingzhj.pdf";
		} else if (nurseType == 2) {
			remoteUrl+="tebiehj.pdf";
		} else if (nurseType == 3) {
			remoteUrl+="bingwhj.pdf";
		} else if (nurseType == 4) {
			remoteUrl+="yibanhj.pdf";
		} else if (nurseType == 5) {
			remoteUrl+="tiwen.pdf";
		} else if (nurseType == 6) {
			remoteUrl+="xuetcd.pdf";
		} else if (nurseType == 7) {
			remoteUrl+="xindjc.pdf";
		} else if (nurseType == 8) {
			remoteUrl+="smtzgc.pdf";
		}
		 
		window.open(remoteUrl);		
	}
	
</script>










